home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / utility / blrmu13.zip / BEEPN.ASM < prev    next >
Assembly Source File  |  1991-01-28  |  4KB  |  132 lines

  1. page ,132
  2. title beepn ( sound n beeps ) as of 01/28/91 - 10:45 pm
  3. ;
  4. ;*-------------------------------------------------
  5. ;
  6. ;        beepn
  7. ;
  8. ;        beeps n times
  9. ;
  10. ;        syntax : beepn n ( n = 1 - 9 )
  11. ;
  12. ;   error checking:
  13. ;
  14. ;        if n = 1 - 9, then n is ok
  15. ;
  16. ;        if n < 1 or n > 9, then n is set to 1
  17. ;
  18. ;        if no n, the n is set to 1
  19. ;
  20. ;*-------------------------------------------------
  21. ;
  22. ;*---------------------------------
  23. was      macro  nos
  24.          local  loop
  25. ;*---------------------------------
  26. ;*   wait a sec
  27. ;*---------------------------------
  28. ;*   nos = number of seconds
  29. ;*---------------------------------
  30.          push  cx                     ; save cx
  31.          mov   ah,44                  ; get current time
  32.          int   33                     ; dos call
  33.          mov   bh,dh                  ; get seconds
  34.          add   bh,nos                 ; add requested seconds
  35.          cmp   bh,60                  ; check for max seconds
  36.          jl    loop                   ; if lo, loop
  37.          sub   bh,60                  ; adjust seconds
  38. loop:
  39.          mov   ah,44                  ; get current time
  40.          int   33                     ; dos call
  41.          cmp   bh,dh                  ; requested delay complete ?
  42.          jne   loop                   ; if not, carry on
  43.          pop   cx                     ; restore cx
  44.          endm
  45. ;*-------------------------------------
  46. cseg     segment para public 'beepn'
  47. ;*-------------------------------------
  48. ;
  49.          assume cs:cseg,ds:cseg,ss:cseg,es:cseg
  50. ;
  51.          org   128
  52. ;
  53. pl       db    0                       ; parm len = space + amt
  54.          db    0                       ; space
  55. amt      db    0,0                     ; beep amount
  56. ;
  57. scl      db    0                       ; save cl
  58. ;
  59.          org   256                     ; where to start
  60. ;
  61. go:      jmp   beep                    ; jump around msg
  62. ;
  63. Beephdg  db    13,10,10
  64.          db    '***   Beeping '
  65. beepv    db    ' '
  66.          db    ' Times   ***'
  67.          db    13,10,10,'$'
  68. ;
  69. beep:
  70. ;
  71.          cmp   pl,0                    ; no parm
  72.          je    ma1                     ; if so, make 1
  73. ;
  74.          cmp  pl,2                     ; 1 digit + space ?
  75.          je   pod                      ; if so, process one digit
  76.          jmp  ma1                      ; if not, make 1
  77. ;
  78. ;   process one digit
  79. ;
  80. pod:
  81.          cld                           ; forward
  82.          lea   si,amt                  ; ptr to amt
  83.          lodsb                         ; put it in al
  84.          and   al,15                   ; make ascii binary
  85.          mov   ch,0                    ; clear ch
  86.          mov   cl,al                   ; mov al to cl
  87. ;
  88. ;        validate amt between 1 - 9
  89. ;
  90.          cmp   cl,1                    ; amt = 1 ?
  91.          jb    ma1                     ; if LT, make amt 1
  92. ;
  93.          cmp   cl,9                    ; amt = 9 ?
  94.          ja    ma1                     ; if GT, make amt 1
  95. ;
  96.          jmp   cll                     ; ok, do the loop
  97. ;
  98. ma1:
  99.          mov   ch,0                    ; clear hi byte
  100.          mov   cl,1                    ; make amt 1
  101. ;
  102. cll:
  103. ;
  104.          mov   scl,cl                  ; save beep amt
  105. ;
  106.          mov   al,cl                   ; convert
  107.          mov   bl,1                    ; it
  108.          lea   si,beepv                ; for
  109.          call  cbtas                   ; msg
  110. ;
  111.          lea   dx,beephdg              ; display
  112.          mov   ah,9h                   ; the
  113.          int   21h                     ; heading
  114. ;
  115.          mov   cl,scl                  ; restore beep amt
  116. ;
  117. beeploop:
  118. ;
  119.          mov   dl, 7                   ; beep char
  120.          mov   ah,2                    ; char out
  121.          int   33                      ; send beep
  122.          was   1                       ; wait 1 second
  123.          loop  beeploop                ; do it n times
  124. ;
  125.          mov   ax,4C00H                ; terminate with 0 ret code
  126.          int   33                      ; exit
  127. ;
  128.          include cbtas.prc
  129. ;
  130. cseg     ends
  131.          end   go
  132.